//
//  Kylin_NewFeatureCollectionViewCell.m
//  01-LotteryBaseFrame
//
//  Created by Kylin on 16/1/7.
//  Copyright © 2016年 kylin. All rights reserved.
//

#import "Kylin_NewFeatureCollectionViewCell.h"
#import "Kylin_TaBarViewController.h"
@interface Kylin_NewFeatureCollectionViewCell()
@property (nonatomic,weak)UIImageView *bgImageView;
@property (nonatomic,weak)UIButton *startButton;
@end
@implementation Kylin_NewFeatureCollectionViewCell

- (UIButton *)startButton{
    if (!_startButton) {
        UIButton *startButton = [[UIButton alloc]init];
        [startButton setBackgroundImage:[UIImage imageNamed:@"guideStart"] forState:UIControlStateNormal];
        
        [startButton sizeToFit];
        

        // 设置frame
        startButton.center = CGPointMake(self.width * 0.5, self.height * 0.9);
        
        [self.contentView addSubview:startButton];
        
        _startButton = startButton;
        
        
        // 点击按钮触发事件
        [startButton addTarget:self action:@selector(ButtonOnClick) forControlEvents:UIControlEventTouchUpInside];
    }
    return _startButton;
}

- (void)ButtonOnClick{
    
    Kylin_TaBarViewController *tabBarVC = [[Kylin_TaBarViewController alloc]init];
    
    Kylin_keyWindow.rootViewController = tabBarVC;
}
// 实现懒加载
- (UIImageView *)bgImageView{
    if (!_bgImageView) {
        UIImageView *bgImageview = [[UIImageView alloc]initWithFrame:self.bounds];
        
        // 将图片添中到contentView上
        [self.contentView addSubview:bgImageview];
        
        _bgImageView = bgImageview;
    }
    
    return _bgImageView;
}

- (void)setImage:(UIImage *)image{
    _image = image;
    
    // 给contentView设置图片
    self.bgImageView.image = image;
}


// 如果是最后一页,就显示startButton
- (void)setIndexPath:(NSIndexPath *)indexPath count:(NSInteger)count{
    if (indexPath.item == count - 1) {
        self.startButton.hidden = NO;
    }else{
        self.startButton.hidden = YES;
    }
}
@end
